﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using ZX.HIS.IDAL;
using ZX.HIS.DBUtility;
using ZX.HIS.Common;
using System.Collections.Generic;//Please add references
namespace ZX.HIS.SQLServerDAL
{
    /// <summary>
    /// 数据访问类:DrugWareHouse
    /// </summary>
    public partial class DrugWareHouse : IDrugWareHouse
    {
        public DrugWareHouse()
        { }
        #region Depart自写方法
        /// <summary>
        /// 药品入库表分页显示
        /// </summary>
        /// <param name="StockID"></param>
        /// <param name="PostDate"></param>
        /// <param name="PostDate1"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        public List<ZX.HIS.Model.DrugWareHouse> DrugWareHouseshow(int ProductId, string PostDate, string PostDate1, int PageIndex, int PageSize)
        {
            StringBuilder db = new StringBuilder();
            // db.Append("select * from( select ROW_NUMBER() over (order by DrugWareId ) r, a.*,b.NewsTypeName  from tbNewsInfo a inner join tbNewsType b on  a.NewsTypeId=b.NewsTypeId where 1=1 ");
            db.Append("SELECT * FROM ( ");
            db.Append("SELECT row_number() over(");
            db.Append("order by DrugWareId desc");
            db.Append(")AS aa, tbDrugWareHouse.DrugWareId,tbHospital.HospitalName,");
            db.Append("tbDrugWareHouse.HospitalId,tbDrugWareHouse.DrugWareName,");
            db.Append("tbDrugWareHouse.DrugWarePackSpece,");
            db.Append("tbDrugWareHouse.ProductId,tbDrugWareHouse.DrugWareNumber,");
            db.Append("tbDrugWareHouse.DrugPurchasePrice,tbDrugWareHouse.DrugWarePresPrice,tbDrugWareHouse.DrugWareBatchNo,");
            db.Append("tbDrugWareHouse.DrugWareTime,tbDrugWareHouse.UserId,tbProduct.ProductName,tbDrugWareHouse.DrugNowDate");
            db.Append(" from tbDrugWareHouse INNER JOIN tbHospital on tbDrugWareHouse.HospitalId=tbHospital.HospitalId");
            db.Append(" inner join tbProduct on tbDrugWareHouse.ProductId= tbProduct.ProductId ");
            db.Append(" WHERE 1=1");
            if (ProductId != 0)
            {
                db.Append("  and  tbDrugWareHouse.ProductId='" + ProductId + "' ");
            }
            if (PostDate1 != "1900-01-01")
            {
                db.Append("  and  tbDrugWareHouse.DrugWareTime<'" + PostDate1 + "' ");
            }
            if (PostDate != "1900-01-01")
            {
                db.Append("  and  tbDrugWareHouse.DrugWareTime>'" + PostDate + "' ");
            }
            db.Append(" ) pp where aa between " + ((PageIndex - 1) * PageSize + 1) + " and " + (PageIndex * PageSize) + "");
            return SqlDBhelper.GetList<ZX.HIS.Model.DrugWareHouse>(db.ToString());
        }
        /// <summary>
        /// 入库表的list集合
        /// </summary>
        /// <returns></returns>
        public List<ZX.HIS.Model.DrugWareHouse> DrugWareHouseList()
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("SELECT tbDrugWareHouse.DrugWareId,tbHospital.HospitalName,tbDrugWareHouse.HospitalId,tbDrugWareHouse.DrugWareName,tbDrugWareHouse.DrugWarePackSpece,tbDrugWareHouse.ProductId,tbDrugWareHouse.DrugWareNumber,tbDrugWareHouse.DrugPurchasePrice,tbDrugWareHouse.DrugWarePresPrice,tbDrugWareHouse.DrugWareBatchNo,tbDrugWareHouse.DrugWareTime,tbDrugWareHouse.UserId,tbProduct.ProductName from tbDrugWareHouse left JOIN tbHospital on tbDrugWareHouse.HospitalId=tbHospital.HospitalId left join tbProduct on tbDrugWareHouse.ProductId= tbProduct.ProductId");
            return SqlDBhelper.GetList<ZX.HIS.Model.DrugWareHouse>(sql.ToString());
        }
        /// <summary>
        /// 总条数
        /// </summary>
        /// <param name="StockID"></param>
        /// <param name="PostDate"></param>
        /// <param name="PostDate1"></param>
        /// <returns></returns>
        public int PageInCount(int ProductId, string PostDate, string PostDate1)
        {
            StringBuilder db = new StringBuilder();
            db.Append("SELECT count(*) from ");
            db.Append("tbDrugWareHouse INNER JOIN tbHospital on tbDrugWareHouse.HospitalId=tbHospital.HospitalId");

            db.Append("   inner join tbProduct on tbDrugWareHouse.ProductId= tbProduct.ProductId WHERE 1=1 ");
            if (ProductId != 0)
            {
                db.Append("  and  tbDrugWareHouse.ProductId='" + ProductId + "' ");
            }
            if (PostDate != "1900-01-01")
            {
                db.Append("  and  tbDrugWareHouse.DrugWareTime>'" + PostDate + "' ");
            }
            if (PostDate1 != "1900-01-01")
            {
                db.Append("  and  tbDrugWareHouse.DrugWareTime<'" + PostDate1 + "' ");
            }
            return SqlDBhelper.ExecuteScalarInt(db.ToString());
        }
        /// <summary>
        /// 添加库存
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public int DrugWareHouseAdd(ZX.HIS.Model.DrugWareHouse mode)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("");
            sql.AppendLine("INSERT INTO tbDrugWareHouse");
            sql.AppendLine("(HospitalId,DrugWareName,DrugWarePackSpece,ProductId,DrugWareNumber,DrugPurchasePrice,DrugWarePresPrice,DrugWareBatchNo,DrugWareTime,UserId,DrugNowDate)");
            sql.AppendLine("VALUES");
            sql.AppendLine("(@HospitalId,@DrugWareName,@DrugWarePackSpece,@ProductId,@DrugWareNumber,@DrugPurchasePrice,@DrugWarePresPrice,@DrugWareBatchNo,@DrugWareTime,@UserId,@DrugNowDate)");
            sql.AppendLine(";select @@IDENTITY");
            SqlParameter[] paemeter ={
                                         new  SqlParameter("@HospitalId",SqlDbType.Int),
                                         new  SqlParameter("@DrugWareName",SqlDbType.VarChar,100),
                                         new  SqlParameter("@DrugWarePackSpece",SqlDbType.VarChar,100),
                                         new  SqlParameter("@ProductId",SqlDbType.Int),
                                         new  SqlParameter("@DrugWareNumber",SqlDbType.Int),
                                         new SqlParameter("@DrugPurchasePrice",SqlDbType.Decimal),
                                         new  SqlParameter("@DrugWarePresPrice",SqlDbType.Decimal),
                                         new  SqlParameter("@DrugWareBatchNo",SqlDbType.Int),
                                         new  SqlParameter("@DrugWareTime",SqlDbType.DateTime),
                                         new  SqlParameter("@UserId",SqlDbType.Int),
                                        new  SqlParameter("@DrugNowDate",SqlDbType.DateTime),
                        };
            paemeter[0].Value = mode.HospitalId;
            paemeter[1].Value = mode.DrugWareName;
            paemeter[2].Value = mode.DrugWarePackSpece;
            paemeter[3].Value = mode.ProductId;
            paemeter[4].Value = mode.DrugWareNumber;
            paemeter[5].Value = mode.DrugPurchasePrice;
            paemeter[6].Value = mode.DrugWarePresPrice;
            paemeter[7].Value = mode.DrugWareBatchNo;
            paemeter[8].Value = mode.DrugWareTime;
            paemeter[9].Value = mode.UserId;
            paemeter[10].Value = mode.DrugNowDate;

            return SqlDBhelper.ExecuteNonQuery(sql.ToString(), paemeter);
        }
        /// <summary>
        /// 修改药品库存表
        /// </summary>
        /// <param name="DWModel"></param>
        /// <returns></returns>
        public bool DrugWareHouseUpt(ZX.HIS.Model.DrugWareHouse DWModel)
        {
            string Comtext = "Proc_DrugWareHouseUpt";
            SqlParameter[] parameters ={
                        new SqlParameter("DrugWareNumber",SqlDbType.VarChar,20){Value=DWModel.DrugWareNumber},
                        new SqlParameter("DrugWareBatchNo",SqlDbType.Int,4){Value=DWModel.DrugWareBatchNo},
                        new SqlParameter("DrugWareTime",SqlDbType.DateTime,4){Value=DWModel.DrugWareTime},
                        new SqlParameter("DrugPurchasePrice",SqlDbType.Decimal,18){Value=DWModel.DrugPurchasePrice},
                        new SqlParameter("DrugWarePresPrice",SqlDbType.Decimal,18){Value=DWModel.DrugWarePresPrice},
                        new SqlParameter("DrugWareId",SqlDbType.Int,8){Value=DWModel.DrugWareId}
                    
                                      };
            return SqlDBhelper.RunProcedureNonQuery(Comtext, parameters);
        }
        /// <summary>
        /// 菜单预警的分页（存储过程）
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="DModel"></param>
        /// <returns></returns>
        public PageClass<ZX.HIS.Model.DrugWareHouse> DrugWarePageList(int PageIndex, int PageSize, ZX.HIS.Model.DrugWareHouse DModel)
        {
          
            SqlParameter[] parameters ={
                                         new SqlParameter("@PageIndex",SqlDbType.Int,8){Value=PageIndex},
                                         new SqlParameter("@PageSize",SqlDbType.Int,8){Value=PageSize},
                                         new SqlParameter("@ProductId",SqlDbType.Int,8){Value=DModel.ProductId},
                                         new SqlParameter("@HospitalId",SqlDbType.Int,8){Value=DModel.HospitalId}
                                     };
            int PageNum = 0;
            List<ZX.HIS.Model.DrugWareHouse> dlist = new List<Model.DrugWareHouse>();
            // DataTable dt = SqlDBhelper.RunProcedure(Comtext, parameters, PageSize, PageIndex, out PageNum);
            DataTable dt = SqlDBhelper.RunProcedure("Proc_DrugWareHouseList", parameters, PageSize, PageIndex, out  PageNum);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
               DModel = new Model.DrugWareHouse();
               DModel.DrugWareId= Convert.ToInt32( dt.Rows[i]["DrugWareId"]);
               DModel.HospitalId =Convert.ToInt32( dt.Rows[i]["HospitalId"]);
               DModel.DrugWareName = dt.Rows[i]["DrugWareName"].ToString();
               DModel.DrugWarePackSpece = dt.Rows[i]["DrugWarePackSpece"].ToString();
               DModel.ProductId =Convert.ToInt32( dt.Rows[i]["ProductId"]);
               DModel.ProductName = dt.Rows[i]["ProductName"].ToString();
               DModel.DrugWareNumber =Convert.ToInt32( dt.Rows[i]["DrugWareNumber"]);
               DModel.DrugPurchasePrice =Convert.ToDecimal( dt.Rows[i]["DrugPurchasePrice"]);
               DModel.DrugWarePresPrice = Convert.ToDecimal( dt.Rows[i]["DrugWarePresPrice"]);
               DModel.DrugWareBatchNo =Convert.ToInt32( dt.Rows[i]["DrugWareBatchNo"]);
               DModel.DrugWareTime =Convert.ToDateTime( dt.Rows[i]["DrugWareTime"]);
               DModel.UserId =Convert.ToInt32( dt.Rows[i]["UserId"]);
               dlist.Add(DModel);
            }
            PageClass<ZX.HIS.Model.DrugWareHouse> Page = new PageClass<Model.DrugWareHouse>();
            Page.PageIndex = PageIndex;
            Page.PageSize = PageSize;
            Page.PageNum = PageNum;
            Page.PageCount = PageNum / PageSize;
            int PageCount = PageNum % PageSize;
            Page.PageList = dlist;
            if (PageCount > 0)
            {
                Page.PageCount = Page.PageCount + 1;
            }
            return Page;
        }

        /// <summary>
        /// 有效期的查询(存储过程)
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="DModel"></param>
        /// <returns></returns>

        public PageClass<ZX.HIS.Model.DrugWareHouse> DrugWareHousePageList(int PageIndex, int PageSize, ZX.HIS.Model.DrugWareHouse DModel)
        {
            string ConTex = "Proc_ValidityPageList";
            SqlParameter[] Parameter ={
                                          new SqlParameter("@PageIndex",SqlDbType.Int,8){Value=PageIndex},
                                          new SqlParameter("@PageSize",SqlDbType.Int,8){Value=PageSize},
                                          new SqlParameter("@DrugTypeId",SqlDbType.VarChar,200){Value=DModel.DrugTypeId},
                                          new SqlParameter("@DrugWareTime",SqlDbType.VarChar,200){Value=DModel.DrugWareTime.ToString("yyyy/MM/dd")},
                                      };
            int PageNum = 0;

            List<ZX.HIS.Model.DrugWareHouse> list = new List<Model.DrugWareHouse>();

            DataTable dt = SqlDBhelper.RunProcedure(ConTex, Parameter, PageSize, PageIndex, out PageNum);
            for (int i = 0; i <dt.Rows.Count ; i++)
            {
               DModel = new Model.DrugWareHouse();
               DModel.DrugWareName = dt.Rows[i]["DrugWareName"].ToString();
               DModel.ProductId =Convert.ToInt32( dt.Rows[i]["ProductId"]);
               DModel.DrugWareNumber =Convert.ToInt32( dt.Rows[i]["DrugWareNumber"]);
               DModel.DrugWarePackSpece = dt.Rows[i]["DrugWarePackSpece"].ToString();
               DModel.DrugWareBatchNo =Convert.ToInt32( dt.Rows[i]["DrugWareBatchNo"]);
               DModel.DrugWareTime =Convert.ToDateTime( dt.Rows[i]["DrugWareTime"]);
               DModel.DrugTypeId = dt.Rows[i]["DrugTypeId"].ToString() ;
               list.Add(DModel);
            }

            PageClass<ZX.HIS.Model.DrugWareHouse> page = new PageClass<Model.DrugWareHouse>();
            page.PageIndex = PageIndex;
            page.PageSize = PageSize;
            page.PageNum = PageNum;
            page.PageCount = PageNum / PageSize;
            int pagecount = PageNum % PageSize;
            if (pagecount > 0)
            {
                page.PageCount = page.PageCount + 1;
            }
            page.PageList = list;
            return page;
        }
        #endregion
        #region  BasicMethod

        ///// <summary>
        ///// 得到最大ID
        ///// </summary>
        //public int GetMaxId()
        //{
        //return DbHelperSQL.GetMaxID("DrugWareId", "tbDrugWareHouse"); 
        //}

        ///// <summary>
        ///// 是否存在该记录
        ///// </summary>
        //public bool Exists(int DrugWareId)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select count(1) from tbDrugWareHouse");
        //    strSql.Append(" where DrugWareId=@DrugWareId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@DrugWareId", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = DrugWareId;

        //    return DbHelperSQL.Exists(strSql.ToString(),parameters);
        //}


        ///// <summary>
        ///// 增加一条数据
        ///// </summary>
        //public int Add(ZX.HIS.Model.DrugWareHouse model)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("insert into tbDrugWareHouse(");
        //    strSql.Append("HospitalId,DrugWareName,DrugWarePackSpece,OpenDoseName,ProductId,DrugWareNumber,DrugWarePresPrice,DrugWareBatchNo,DrugWareTime,UserId)");
        //    strSql.Append(" values (");
        //    strSql.Append("@HospitalId,@DrugWareName,@DrugWarePackSpece,@OpenDoseName,@ProductId,@DrugWareNumber,@DrugWarePresPrice,@DrugWareBatchNo,@DrugWareTime,@UserId)");
        //    strSql.Append(";select @@IDENTITY");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@HospitalId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugWareName", SqlDbType.VarChar,100),
        //            new SqlParameter("@DrugWarePackSpece", SqlDbType.VarChar,100),
        //            new SqlParameter("@OpenDoseName", SqlDbType.Int,4),
        //            new SqlParameter("@ProductId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugWareNumber", SqlDbType.Int,4),
        //            new SqlParameter("@DrugWarePresPrice", SqlDbType.Decimal,9),
        //            new SqlParameter("@DrugWareBatchNo", SqlDbType.Int,4),
        //            new SqlParameter("@DrugWareTime", SqlDbType.DateTime),
        //            new SqlParameter("@UserId", SqlDbType.Int,4)};
        //    parameters[0].Value = model.HospitalId;
        //    parameters[1].Value = model.DrugWareName;
        //    parameters[2].Value = model.DrugWarePackSpece;
        //    parameters[3].Value = model.OpenDoseName;
        //    parameters[4].Value = model.ProductId;
        //    parameters[5].Value = model.DrugWareNumber;
        //    parameters[6].Value = model.DrugWarePresPrice;
        //    parameters[7].Value = model.DrugWareBatchNo;
        //    parameters[8].Value = model.DrugWareTime;
        //    parameters[9].Value = model.UserId;

        //    object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
        //    if (obj == null)
        //    {
        //        return 0;
        //    }
        //    else
        //    {
        //        return Convert.ToInt32(obj);
        //    }
        //}
        ///// <summary>
        ///// 更新一条数据
        ///// </summary>
        //public bool Update(ZX.HIS.Model.DrugWareHouse model)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("update tbDrugWareHouse set ");
        //    strSql.Append("HospitalId=@HospitalId,");
        //    strSql.Append("DrugWareName=@DrugWareName,");
        //    strSql.Append("DrugWarePackSpece=@DrugWarePackSpece,");
        //    strSql.Append("OpenDoseName=@OpenDoseName,");
        //    strSql.Append("ProductId=@ProductId,");
        //    strSql.Append("DrugWareNumber=@DrugWareNumber,");
        //    strSql.Append("DrugWarePresPrice=@DrugWarePresPrice,");
        //    strSql.Append("DrugWareBatchNo=@DrugWareBatchNo,");
        //    strSql.Append("DrugWareTime=@DrugWareTime,");
        //    strSql.Append("UserId=@UserId");
        //    strSql.Append(" where DrugWareId=@DrugWareId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@HospitalId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugWareName", SqlDbType.VarChar,100),
        //            new SqlParameter("@DrugWarePackSpece", SqlDbType.VarChar,100),
        //            new SqlParameter("@OpenDoseName", SqlDbType.Int,4),
        //            new SqlParameter("@ProductId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugWareNumber", SqlDbType.Int,4),
        //            new SqlParameter("@DrugWarePresPrice", SqlDbType.Decimal,9),
        //            new SqlParameter("@DrugWareBatchNo", SqlDbType.Int,4),
        //            new SqlParameter("@DrugWareTime", SqlDbType.DateTime),
        //            new SqlParameter("@UserId", SqlDbType.Int,4),
        //            new SqlParameter("@DrugWareId", SqlDbType.Int,4)};
        //    parameters[0].Value = model.HospitalId;
        //    parameters[1].Value = model.DrugWareName;
        //    parameters[2].Value = model.DrugWarePackSpece;
        //    parameters[3].Value = model.OpenDoseName;
        //    parameters[4].Value = model.ProductId;
        //    parameters[5].Value = model.DrugWareNumber;
        //    parameters[6].Value = model.DrugWarePresPrice;
        //    parameters[7].Value = model.DrugWareBatchNo;
        //    parameters[8].Value = model.DrugWareTime;
        //    parameters[9].Value = model.UserId;
        //    parameters[10].Value = model.DrugWareId;

        //    int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
        //    if (rows > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}

        ///// <summary>
        ///// 删除一条数据
        ///// </summary>
        //public bool Delete(int DrugWareId)
        //{

        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("delete from tbDrugWareHouse ");
        //    strSql.Append(" where DrugWareId=@DrugWareId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@DrugWareId", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = DrugWareId;

        //    int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
        //    if (rows > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
        ///// <summary>
        ///// 批量删除数据
        ///// </summary>
        //public bool DeleteList(string DrugWareIdlist )
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("delete from tbDrugWareHouse ");
        //    strSql.Append(" where DrugWareId in ("+DrugWareIdlist + ")  ");
        //    int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
        //    if (rows > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}


        ///// <summary>
        ///// 得到一个对象实体
        ///// </summary>
        //public ZX.HIS.Model.DrugWareHouse GetModel(int DrugWareId)
        //{

        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select  top 1 DrugWareId,HospitalId,DrugWareName,DrugWarePackSpece,OpenDoseName,ProductId,DrugWareNumber,DrugWarePresPrice,DrugWareBatchNo,DrugWareTime,UserId from tbDrugWareHouse ");
        //    strSql.Append(" where DrugWareId=@DrugWareId");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@DrugWareId", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = DrugWareId;

        //    ZX.HIS.Model.DrugWareHouse model=new ZX.HIS.Model.DrugWareHouse();
        //    DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
        //    if(ds.Tables[0].Rows.Count>0)
        //    {
        //        return DataRowToModel(ds.Tables[0].Rows[0]);
        //    }
        //    else
        //    {
        //        return null;
        //    }
        //}


        ///// <summary>
        ///// 得到一个对象实体
        ///// </summary>
        //public ZX.HIS.Model.DrugWareHouse DataRowToModel(DataRow row)
        //{
        //    ZX.HIS.Model.DrugWareHouse model=new ZX.HIS.Model.DrugWareHouse();
        //    if (row != null)
        //    {
        //        if(row["DrugWareId"]!=null && row["DrugWareId"].ToString()!="")
        //        {
        //            model.DrugWareId=int.Parse(row["DrugWareId"].ToString());
        //        }
        //        if(row["HospitalId"]!=null && row["HospitalId"].ToString()!="")
        //        {
        //            model.HospitalId=int.Parse(row["HospitalId"].ToString());
        //        }
        //        if(row["DrugWareName"]!=null)
        //        {
        //            model.DrugWareName=row["DrugWareName"].ToString();
        //        }
        //        if(row["DrugWarePackSpece"]!=null)
        //        {
        //            model.DrugWarePackSpece=row["DrugWarePackSpece"].ToString();
        //        }
        //        if(row["OpenDoseName"]!=null && row["OpenDoseName"].ToString()!="")
        //        {
        //            model.OpenDoseName=int.Parse(row["OpenDoseName"].ToString());
        //        }
        //        if(row["ProductId"]!=null && row["ProductId"].ToString()!="")
        //        {
        //            model.ProductId=int.Parse(row["ProductId"].ToString());
        //        }
        //        if(row["DrugWareNumber"]!=null && row["DrugWareNumber"].ToString()!="")
        //        {
        //            model.DrugWareNumber=int.Parse(row["DrugWareNumber"].ToString());
        //        }
        //        if(row["DrugWarePresPrice"]!=null && row["DrugWarePresPrice"].ToString()!="")
        //        {
        //            model.DrugWarePresPrice=decimal.Parse(row["DrugWarePresPrice"].ToString());
        //        }
        //        if(row["DrugWareBatchNo"]!=null && row["DrugWareBatchNo"].ToString()!="")
        //        {
        //            model.DrugWareBatchNo=int.Parse(row["DrugWareBatchNo"].ToString());
        //        }
        //        if(row["DrugWareTime"]!=null && row["DrugWareTime"].ToString()!="")
        //        {
        //            model.DrugWareTime=DateTime.Parse(row["DrugWareTime"].ToString());
        //        }
        //        if(row["UserId"]!=null && row["UserId"].ToString()!="")
        //        {
        //            model.UserId=int.Parse(row["UserId"].ToString());
        //        }
        //    }
        //    return model;
        //}

        ///// <summary>
        ///// 获得数据列表
        ///// </summary>
        //public DataSet GetList(string strWhere)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select DrugWareId,HospitalId,DrugWareName,DrugWarePackSpece,OpenDoseName,ProductId,DrugWareNumber,DrugWarePresPrice,DrugWareBatchNo,DrugWareTime,UserId ");
        //    strSql.Append(" FROM tbDrugWareHouse ");
        //    if(strWhere.Trim()!="")
        //    {
        //        strSql.Append(" where "+strWhere);
        //    }
        //    return DbHelperSQL.Query(strSql.ToString());
        //}

        ///// <summary>
        ///// 获得前几行数据
        ///// </summary>
        //public DataSet GetList(int Top,string strWhere,string filedOrder)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select ");
        //    if(Top>0)
        //    {
        //        strSql.Append(" top "+Top.ToString());
        //    }
        //    strSql.Append(" DrugWareId,HospitalId,DrugWareName,DrugWarePackSpece,OpenDoseName,ProductId,DrugWareNumber,DrugWarePresPrice,DrugWareBatchNo,DrugWareTime,UserId ");
        //    strSql.Append(" FROM tbDrugWareHouse ");
        //    if(strWhere.Trim()!="")
        //    {
        //        strSql.Append(" where "+strWhere);
        //    }
        //    strSql.Append(" order by " + filedOrder);
        //    return DbHelperSQL.Query(strSql.ToString());
        //}

        ///// <summary>
        ///// 获取记录总数
        ///// </summary>
        //public int GetRecordCount(string strWhere)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("select count(1) FROM tbDrugWareHouse ");
        //    if(strWhere.Trim()!="")
        //    {
        //        strSql.Append(" where "+strWhere);
        //    }
        //    object obj = DbHelperSQL.GetSingle(strSql.ToString());
        //    if (obj == null)
        //    {
        //        return 0;
        //    }
        //    else
        //    {
        //        return Convert.ToInt32(obj);
        //    }
        //}
        ///// <summary>
        ///// 分页获取数据列表
        ///// </summary>
        //public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        //{
        //    StringBuilder strSql=new StringBuilder();
        //    strSql.Append("SELECT * FROM ( ");
        //    strSql.Append(" SELECT ROW_NUMBER() OVER (");
        //    if (!string.IsNullOrEmpty(orderby.Trim()))
        //    {
        //        strSql.Append("order by T." + orderby );
        //    }
        //    else
        //    {
        //        strSql.Append("order by T.DrugWareId desc");
        //    }
        //    strSql.Append(")AS Row, T.*  from tbDrugWareHouse T ");
        //    if (!string.IsNullOrEmpty(strWhere.Trim()))
        //    {
        //        strSql.Append(" WHERE " + strWhere);
        //    }
        //    strSql.Append(" ) TT");
        //    strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
        //    return DbHelperSQL.Query(strSql.ToString());
        //}

        ///*
        ///// <summary>
        ///// 分页获取数据列表
        ///// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@tblName", SqlDbType.VarChar, 255),
        //            new SqlParameter("@fldName", SqlDbType.VarChar, 255),
        //            new SqlParameter("@PageSize", SqlDbType.Int),
        //            new SqlParameter("@PageIndex", SqlDbType.Int),
        //            new SqlParameter("@IsReCount", SqlDbType.Bit),
        //            new SqlParameter("@OrderType", SqlDbType.Bit),
        //            new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
        //            };
        //    parameters[0].Value = "tbDrugWareHouse";
        //    parameters[1].Value = "DrugWareId";
        //    parameters[2].Value = PageSize;
        //    parameters[3].Value = PageIndex;
        //    parameters[4].Value = 0;
        //    parameters[5].Value = 0;
        //    parameters[6].Value = strWhere;	
        //    return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        //}*/

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

